* gtk/gtkcalendar.c: Release the memory returned by the detail_func.
* gtk/gtkcalendar.h: Remove G_CONST_RETURN from GtkCalendarDetailFunc.
* tests/testcalendar.c: Duplicate calendar details before returning.
svn path=/trunk/; revision=19382
+2008-01-16 Mathias Hasselmann <mathias@openismus.com>
+
+ Change GtkCalendarDetailFunc to return newly allocated string. (#339540)
+
+ * gtk/gtkcalendar.c: Release the memory returned by the detail_func.
+ * gtk/gtkcalendar.h: Remove G_CONST_RETURN from GtkCalendarDetailFunc.
+ * tests/testcalendar.c: Duplicate calendar details before returning.
+
2008-01-16 Christian Persch <chpe@gnome.org>
* gtk/gtkwidget.c: Store the event mask and extension event mode
(* GTK_WIDGET_CLASS (gtk_calendar_parent_class)->unrealize) (widget);
}
-static G_CONST_RETURN gchar*
+static gchar*
gtk_calendar_get_detail (GtkCalendar *calendar,
gint row,
gint column)
{
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget);
GtkCalendar *calendar = GTK_CALENDAR (widget);
- const gchar *detail = NULL;
+ gchar *detail = NULL;
GdkRectangle day_rect;
if (priv->main_win)
gtk_tooltip_set_tip_area (tooltip, &day_rect);
gtk_tooltip_set_markup (tooltip, detail);
+ g_free (detail);
+
return TRUE;
}
for (r = 0; r < 6; r++)
for (c = 0; c < 7; c++)
{
- const gchar *detail = gtk_calendar_get_detail (calendar, r, c);
+ gchar *detail = gtk_calendar_get_detail (calendar, r, c);
if (detail)
{
max_detail_height = MAX (max_detail_height, logical_rect.height);
g_free (markup);
+ g_free (detail);
}
}
}
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar);
cairo_t *cr;
GdkColor *text_color;
- const gchar *detail;
+ gchar *detail;
gchar buffer[32];
gint day;
gint x_loc, y_loc;
g_object_unref (layout);
cairo_destroy (cr);
+ g_free (detail);
}
static void
*
* Since: 2.16
*
- * Return value: Pango markup with details for the specified day, or %NULL.
+ * Return value: Newly allocated string with Pango markup with details
+ * for the specified day, or %NULL.
*/
-typedef G_CONST_RETURN gchar* (*GtkCalendarDetailFunc) (GtkCalendar *calendar,
- guint year,
- guint month,
- guint day,
- gpointer user_data);
+typedef gchar* (*GtkCalendarDetailFunc) (GtkCalendar *calendar,
+ guint year,
+ guint month,
+ guint day,
+ gpointer user_data);
struct _GtkCalendar
{
g_hash_table_replace (data->details_table, key, detail);
}
-static G_CONST_RETURN gchar*
+static gchar*
calendar_get_detail (CalendarData *data,
guint year,
guint month,
detail = g_hash_table_lookup (data->details_table, key);
g_free (key);
- return detail;
+ return (detail ? g_strdup (detail) : NULL);
}
static void